    //socket监听（推送）
	$(document).ready(function() {
		
		setTimeout(function(){
			var socket = io.connect('http://122.10.87.69:888');
			
			socket.on("needlogin",function(){
				var saf = "mess" + $(".sl").attr('value');
				socket.emit('login',md5("mess" + $(".sl").attr('value')),function(result){
		
				//登陆成功
				});
			});
			
	
			socket.on('user message',function(data)
			{
				$('.badge').html(data.length);
				$('#home').html("");
				$('#profile').html("");
				$('#dropdown1').html("");
				var html = '';
				for(var i = 0;i < data.length;i++)
				{
					var messid = data[i]['mess_id'];
					var type = data[i]['mess_type'];
					var umid = data[i]['send_user_id'];
					var amid = data[i]['article_id'];
					var mid = data[i]['mess_id'];
					var mimg = data[i]['user_img'];
					var mname = data[i]['user_name'];
					var content = data[i]['mess_content'];
					var amcontent = data[i]['article_title'];
					if(amcontent == '')
						var amcontent = data[i]['article_content'];
					if(type <= 2){
						html = 	'<div class="mess mess-close messHide">' +
									'<button class="close refusal" aria-hidden="true" type="button" data-dismiss="mess-close" valueM="' + messid + '" mtype="' + type + '">&times;</button>' +
									'<div class="dropdown-img">' +
										'<a href="'+ urlHispage.substr(0,urlHispage.length - 5) + '/hispage/' + umid +'">' + 
											'<img width="40" src="' + mimg + '">' + 
										'</a>' +
									'</div>' +
									'<div class="dropdown-body">' +
										'<div class="dropdown-title">' +
											'<span>' + 
												'<a href="'+ urlHispage.substr(0,urlHispage.length - 5) + '/hispage/' + umid +'">' +
													mname + 
												'</a>' + 
											'</span>' +
											'说' +
										'</div>' +
										'<div class="dropdown-cont">' +
											'<div class="dropdown-cont-title">' + 
												content + 
											'</div>';
											
						if(type == 1)	
							
							html += 		'<a href="' + urlDiscuss + '?aId=' + + amid + '">';
						else
							html +=			'<a href="' + urlArticle + '?aid=' + + amid + '">';
													
							html +=				amcontent + "......" +
											'</a>' +
										'</div>' +
									'</div>' +
									'<div class="clearfix">' + 
									'</div>' +
								'</div>';	
						$('#home').append(html);
					}
					else if(type >=3 && type <=5)
					{
						html = 	'<div class="coled">' +
								  '<div class="foryou mess-close">' +
										'<button class="close refusal" aria-hidden="true" type="button" data-dismiss="mess-close" valueM="' + messid + '" mtype="' + type + '">&times;</button>' +
										'<div class="dropdown-img">' +
											'<img src="' + mimg + '" width="40" class="img-circle" />' +
										'</div>' +
										'<div class="dropdown-body">' +
											'<div class="dropdown-title">' +
												'<span>' + mname + '</span>';
						if( type == 3)
						{
							html +=				'申请<span class="read-over">加入讨论</span>'
						}
						else if (type == 4)
						{
							html +=				'申请<span class="read-over">批阅</span>'
						}
						else  
						{                                                   
							html +=				'邀请<span class="read-over">参与讨论</span>'
						}
							html +=			'</div>' +
											'<div class="dropdown-cont">' +
														<!--<div class="dropdown-cont-title">擅长：设计、编程</div>-->
												amcontent + "......" +
											'</div>' +
										'</div>' +
										'<div class="clearfix"></div>' +
										'<div class="dropdown-footer hidden">';
					   if (type == 5)
					   {
						   html +=		'<a href="' + urlDiscuss + '?aId=' + + amid + '" >' +
											'<button type="button" class="btn btn-danger allow" valueU="' + umid + '" valueA="' + amid + '" valueM="' + mid +
							'" mtype="' + type + '">' + 
												'进入讨论' + 
											'</button>' + 
										'</a>'
					   }else{
						   html +=      '<button type="button" class="btn btn-primary allow" valueU="' + umid + '" valueA="' + amid + '" valueM="' + mid +
							'" mtype="' + type + '">' + 
											'允许' + 
										'</button>' +
										' <button type="button" class="btn btn-default refusal" valueM="' + mid + '" mtype="' + type + '" >' + 
											'忽略' + 
										'</button>';
					   }
						   html +=       '</div>' +
										'</div>' +
									'</div>';
					
						$('#profile').append(html);
					}else if(type == 6)
					{
							html =	'<div class="discuss mess-close">' +
										'<button class="close refusal" aria-hidden="true" type="button" data-dismiss="mess-close" valueM="' + messid + '" mtype="' + type + '">&times;</button>'+
										'<div class="dropdown-img">'+
											'<img src="' + mimg + '" width="40" class="img-circle" />'+
										'</div>'+
										'<div class="dropdown-body">'+
											'<div class="dropdown-title">'+
												'<span>' + mname + '</span><span class="agree">同意</span>参与'+
											'</div>'+
											'<div class="dropdown-cont">'+
												'<div class="dropdown-cont-title"></div>'+
											   '<a href="' + urlDiscuss + '?aId=' + + amid + '" >' + amcontent + '</a>'+
											'</div>'+
										'</div>'+
										'<div class="clearfix"></div>'+
										'<div class="dropdown-footer hidden">'+
											'<a href="' + urlDiscuss + '?aId=' + + amid +'" ><button type="button" class="btn btn-danger">进入讨论</button></a>' +
										'</div>' +
									'</div>';
							
						$('#dropdown1').append(html);
					}else if(type == 7)
					{
							html =	'<div class="discuss mess-close">' +
										'<button class="close refusal" aria-hidden="true" type="button" data-dismiss="mess-close" valueM="' + messid + '" mtype="' + type + '">&times;</button>'+
										'<div class="dropdown-img">'+
											'<img src="' + mimg + '" width="40" class="img-circle" />'+
										'</div>'+
										'<div class="dropdown-body">'+
											'<div class="dropdown-title">'+
												'<span>' + mname + '</span><span class="agree">同意</span>批阅' +
											'</div>'+
											'<div class="dropdown-cont">'+
												'<div class="dropdown-cont-title"></div>'+
											   '<a href="' + urlDiscuss + '?aId=' + + amid + '" >' + amcontent + '</a>'+
											'</div>'+
										'</div>'+
										'<div class="clearfix"></div>'+
										'<div class="dropdown-footer hidden">'+
											'<a href="' + urlArticle + '?aid=' + + amid +'" ><button type="button" class="btn btn-danger">立即批阅</button></a>' +
										'</div>' +
									'</div>';
							
						$('#dropdown1').append(html);
					}else if(type == 8)
					{
							html =	'<div class="discuss mess-close">' +
										'<button class="close refusal" aria-hidden="true" type="button" data-dismiss="mess-close" valueM="' + messid + '" mtype="' + type + '">&times;</button>'+
										'<div class="dropdown-img">'+
											'<img src="' + mimg + '" width="40" class="img-circle" />'+
										'</div>'+
										'<div class="dropdown-body">'+
											'<div class="dropdown-title">'+
												'<span>' + mname + '</span><span class="agree">同意</span>参与' +
											'</div>'+
											'<div class="dropdown-cont">'+
												'<div class="dropdown-cont-title"></div>'+
											   '<a href="' + urlDiscuss + '?aId=' + + amid + '" >' + amcontent + '</a>'+
											'</div>'+
										'</div>'+
										'<div class="clearfix"></div>'+
										'<div class="dropdown-footer hidden">'+
											'<a href="' + urlDiscuss + '?aId=' + amid +'" ><button type="button" class="btn btn-danger">进入讨论</button></a>' +
										'</div>' +
									'</div>';
							
						$('#dropdown1').append(html);
					}
				}

				messCount();
			});
		},0);
		
		
		
		
		//////////通知允许模块////////////
		$(document).on('click','.allow',function() {
			var umid = $(this).attr('valueu');
			var amid = $(this).attr('valuea');
			var mid = $(this).attr('valuem');
			var type = $(this).attr('mtype');
			var mThis = $(this);
			$.ajax({
				url : urlMessSeek,
				type : 'POST',
				data : {
					"umid" : umid,
					"amid" : amid,
					"mid" : mid,
					"mtype" : type
				},
				success : function(data) {
					mThis.parent().parent('.foryou').hide(500,function(){
						mThis.parent().parent('.foryou').addClass('hidden');
						messCount();
					});
				}
			});
		});
		//////////通知允许模块////////////
		
		
		//////////这是忽略模块//////////
		$(document).on('click','.refusal',function() {
			var mid = $(this).attr('valuem');
			var type = $(this).attr('mtype');
			var mThis = $(this);
			$.ajax({
				url : urlMessIgnore,
				type : 'POST',
				data : {
					"mid" : mid,
					"mtype" : type
				},
				success : function(data) {
					mThis.parent().parent('.foryou').hide(500,function(){
						mThis.parent().parent('.foryou').addClass('hidden');
						messCount();
					});
				}
			});
		});
		//////////这是忽略模块//////////
		
		
		
		
		////////////搜索框////////////
		//header页头搜索按钮点击 
		$(document).on('click','.fa-search',function(){
			$('#search-af').animate({width:'350px',opacity:'1'},1000);
			$('#search-af').show();
			$('#s-input').focus();
		});		
		//header页头按钮鼠标悬停显示提示
		$(document).on('mouseover','.tip-btn',function(){
			$(this).tooltip('show');
		});
		////////////搜索框////////////
		
		$(document).on('mouseenter','.mess-close',function () {
			$(this).find('.dropdown-footer').toggleClass("hidden").animate({ opacity: '1', height: '35px' });
		});
		$(document).on('mouseleave','.mess-close',function () {
			$(this).find('.dropdown-footer').animate({ opacity: '0', height: '0px' }, function () { $(this).toggleClass("hidden")});
		});
		$(document).on('click','.mess-close .close',function () {
			$(this).parent('.mess-close').animate({ opacity: '0', height: '0px' }, function () 
			{
				$(this).addClass("hidden");
				messCount();
			});
		});

		///////////显示消息框////////////		
		$(document).on('click',function (e) {
			if($(e.target).closest('[data-toggle="mess-popover"]').size() > 0)
			{
				$('#mess').fadeToggle();
				return false;
			}
			else if($(e.target).closest('#mess').size() == 0)
				$('#mess').fadeOut();
		});
		
		///////////显示消息框////////////		
		/*返回顶部*/ 
		$('#roll_top').hide(); 
		$(window).scroll(function () { 
			if ($(window).scrollTop() > 0) { 
				$('#roll_top').fadeIn(400);//当滑动栏向下滑动时，按钮渐现的时间 
			} else { 
				$('#roll_top').fadeOut(200);//当页面回到顶部第一屏时，按钮渐隐的时间 
			} 
		}); 
		$('#roll_top').click(function () { 
			$('html,body').animate({ scrollTop : '0px' }, 200);//返回顶部所用的时间  
		});
		
		
		var messCount =  function(){
			$('[data-toggle="mess-popover"] .mess-nord').text(function (i, x) {
				var a = $('#myTabContent .mess-close').not('.hidden').size();
				if(a != 0)
					return a;
				else
					return '';
			});
			$('[href="#home"] .mess-nord').text(function(index, text) {
				var a = $('#home .mess-close').not('.hidden').size();
                if(a != 0)
					return a;
				else
					return '';
            });
			$('[href="#profile"] .mess-nord').text(function (i,x){
				var a = $('#profile .mess-close').not('.hidden').size();
				if(a != 0)
					return a;
				else
					return '';
			});
			$('[href="#dropdown1"] .mess-nord').text(function (i,x){
				var a = $('#dropdown1 .mess-close').not('.hidden').size();
				if(a != 0)
					return a;
				else
					return '';
			});
		}
		messCount();
	});
